/**
 * 
 */
package com.gragra.sampling.sequentialStructure.tests;
import static org.junit.Assert.*;
import java.io.BufferedReader;
import java.io.StringReader;
import org.junit.Before;
import org.junit.Test;
import com.gragra.data.Corpus;
import com.gragra.sampling.sequentialStructure.ExtensionInformationHolder;
import com.gragra.sampling.sequentialStructure.WordAndTagHolder;
import com.gragra.sequentiaDataGenerator.BaseGenerator;
import com.gragra.sequentiaDataGenerator.CaseLevelAssigningSegmenter;
import com.gragra.sequentiaDataGenerator.PunctuationSplitOffSegmenter;
import com.gragra.util.StringToInt;
/**
 * @author Christoph Teichmann
 * created Mar 26, 2013 8:40:34 PM
 * @version 0.1
 */
public class TestWordAndTagHolder
{
	/**
	 * 
	 */
	private WordAndTagHolder wth;
	/**
	 *
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception
	{
		StringReader sr = new StringReader("This|0|WordTypeLevel|Noun IS|NONE something.|0|ContextTagLevel|10 \n this|Pronoun too.|NONE|WordTypeLevel|Function");
		BufferedReader br = new BufferedReader(sr);
		BaseGenerator bg = new BaseGenerator(new CaseLevelAssigningSegmenter(new PunctuationSplitOffSegmenter("NONE")));
		Corpus<WordAndTagHolder> corp = bg.createCorpus(br);
		wth = corp.getEntry(0);
	}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getLength()}.
	 */
	@Test
	public final void testGetLength()
	{assertEquals(wth.getLength(),4);}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getTags()}.
	 */
	@Test
	public final void testGetTags()
	{assertArrayEquals(wth.getTags(),new int[] {StringToInt.ensure("0"),-1,StringToInt.ensure("0"),-1});}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getWords()}.
	 */
	@Test
	public final void testGetWords()
	{assertArrayEquals(wth.getWords(),new int[] {StringToInt.ensure("this"),StringToInt.ensure("is"),StringToInt.ensure("something"),StringToInt.ensure(".")});}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getTags(int, int)}.
	 */
	@Test
	public final void testGetTagsIntInt()
	{assertArrayEquals(wth.getTags(1,3),new int[] {-1,StringToInt.ensure("0")});}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getWords(int, int)}.
	 */
	@Test
	public final void testGetWordsIntInt()
	{assertArrayEquals(wth.getWords(1,3),new int[] {StringToInt.ensure("is"),StringToInt.ensure("something")});}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getTag(int)}.
	 */
	@Test
	public final void testGetTag()
	{assertEquals(-1,wth.getTag(1));}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getWord(int)}.
	 */
	@Test
	public final void testGetWord()
	{
		assertEquals(StringToInt.ensure("is"),wth.getWord(1));
	}
	/**
	 * Test method for {@link com.gragra.sampling.sequentialStructure.WordAndTagHolder#getExtensionInformation()}.
	 */
	@Test
	public final void testGetExtensionInformation()
	{
		ExtensionInformationHolder eih = wth.getExtensionInformation();
		ExtensionInformationHolder eib = wth.getExtensionInformation();
		assertEquals(eih,eib);
	}
}